package com.code.java.concurrent;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/12 16:59
 */
public class Cache<V, K> extends LinkedHashMap<K,V> {
    private final int capacity;
    private static final long serialVersionUID = 1L;

    public Cache(int capacity) {
        super(16, 0.75f, true);
        this.capacity = capacity;
    }

    @Override
    protected boolean removeEldestEntry(Map.Entry eldest) {
        return size() > capacity;
    }
}
